package com.yin.myproject.thread.listblock;

import com.yin.myproject.thread.spinlock.Lock;

/**
 * @author Eason
 * @create 2018-03-08 10:02
 **/
public class Main {
//    private static Lock lock = new ArrayLock(150);
    private static Lock lock = new CLHLock();
    //private static TimeCost timeCost = new TimeCost(new TTASLock());

    private volatile int value = 0;

    public static void main(String[] args) {
        Main main = new Main();
        for (int i = 0; i < 100; i++) {
            Thread t = new Thread(main::method);
            t.start();
        }
    }

    public void method() {
        lock.lock();
        System.out.println(Thread.currentThread().getName() + "Value: " + ++value);
        lock.unlock();
    }
}
